home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / ANTENNA / YAGIU112 / CK_FLAGS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-28  |  2.9 KB  |  84 lines

  1. /* file ck_flags.c */
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include "yagi.h"
  5.  
  6. /* This function checks that all the options are sensible */
  7.  
  8. extern int errno;
  9.  
  10. void check_flags(struct flags flag, int argc, int optind, char *exefilename)
  11. {
  12.     if(flag.errflg)
  13.         usage_optimise(exefilename);        
  14.     if(flag.hflg) /* help flag */
  15.         usage_optimise(exefilename);        
  16.     if(flag.dflg)
  17.         show_all_optimise_parameters(exefilename,flag);
  18.  
  19.     if(flag.gflg && flag.Wflg)
  20.     {
  21.         error_message("\nThe genetic algorithm invoked with the '-g' option must, due to the very nature of genetic algorithms, use a weighted combination of parameters. You need not (nor are you allowed too) specify the '-W' and '-g' options together.\n");
  22.         exit(1);
  23.     }
  24.     if(flag.gflg && flag.rflg)
  25.     {
  26.         error_message("\nYou can not specify the genetic algorithm flag '-g' and also specify the resistance flag '-r' at the same time.\n"); 
  27.         exit(1);
  28.     }
  29.     if(flag.gflg && flag.sflg)
  30.     {
  31.         error_message("\nYou can not specify the genetic algorithm flag '-g' and also specify the swr flag '-s' at the same time. To alter the genetic algorithms behaviour with reguard to swr, change the swr weight with the '-S' flag.\n"); 
  32.         exit(1);
  33.     }
  34.     if(flag.gflg && flag.lflg)
  35.     {
  36.         error_message("\nYou can not specify the genetic algorithm flag '-g' and also specify the flag '-l' at the same time.\n"); 
  37.         exit(1);
  38.     }
  39.     if( (flag.tflg && !flag.Tflg) || (flag.Tflg && !flag.tflg))
  40.     {
  41.         error_message("\nThe options '-t' and '-T' must both be used together. They can not be used with any other options\n");
  42.         exit(1);
  43.     }
  44.     if( flag.tflg &&( flag.bflg || flag.cflg || flag.fflg ||
  45.          flag.gflg || flag.hflg || flag.oflg || flag.pflg || flag.lflg ||
  46.          flag.rflg || flag.sflg || flag.xflg || flag.Fflg ||
  47.          flag.Gflg || flag.Rflg || flag.Cflg || flag.Sflg || flag.Wflg   
  48.          ) )
  49.     {
  50.         error_message("The flags '-t' and '-T' can not be used with one of the other options specified. The only option allowed with them is '-Z' to fix the charaterisitc impedance, '-d'  or '-v'\n");
  51.         exit(1);
  52.     }
  53.     if(flag.cflg && !(flag.gflg || flag.Wflg) )
  54.     {
  55.         error_message("The flag '-c' can only be used with the '-W' or '-g' flags\n");
  56.         exit(1);
  57.     }
  58.     if((flag.Fflg || flag.Gflg || flag.Rflg || flag.Pflg || flag.Sflg || flag.Xflg) && !(flag.gflg || flag.Wflg))
  59.     {
  60.         error_message("The weight flags (F, G, R, P, S and X) must be used either with the genetic algorithm flag (-g) or the the weithted performance flag (-W)\n");
  61.         exit(1);
  62.     }
  63.     if(flag.gflg && flag.wflg)
  64.     {
  65.         error_message("Sorry, the genetic algorithm can't optimise over a wide band yet, so you cant use the -w option\n");
  66.         exit(1);
  67.     }
  68.     if(flag.pflg && ! flag.gflg)
  69.     {
  70.         error_message("The '-p' population size option is only used with the genetic algorithm '-g' option\n");
  71.         exit(1);
  72.     }
  73. if( (argc - optind) != 3 &&  (argc-optind) !=2)
  74.         usage_optimise(exefilename);
  75.  
  76. #ifdef DEBUG
  77.     if(errno)
  78.     {
  79.         fprintf(stderr,"Errno =%d in ck_flags.c\n", errno);
  80.         exit(1);
  81.     }
  82. #endif
  83. }
  84.